#!/bin/bash
#
# 1.Initialize PWM channels
#
# Copyright (c) 2020, Mangdang Technology Co., Limited
#
#

# get hardware version
echo 27 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio27/direction
hw_version_io=`cat /sys/class/gpio/gpio27/value`
echo 27 > /sys/class/gpio/unexport
if [ "$hw_version_io" == "1" ]; then
	sudo echo "P1" > /home/ubuntu/.hw_version
else
	sudo echo "MP" > /home/ubuntu/.hw_version
fi

# export pwm channel
for i in $(seq 0 15)
do
	echo $i > /sys/class/pwm/pwmchip0/export
	echo  4000000 > /sys/class/pwm/pwmchip0/pwm$i/period
done

# set cpu performance
echo performance > /sys/bus/cpu/devices/cpu0/cpufreq/scaling_governor

gsp-play-1.0 /home/ubuntu/Music/power_on.mp3 &
